package AccountBinding

import (
	"ToolLibray/jwtx"
	"context"
	"property_service/property_service"

	"github.com/zeromicro/go-zero/core/logx"
	"property_api/internal/svc"
	"property_api/internal/types"
	"property_api/utils/result"
)

type DeleteLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLogic {
	return &DeleteLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DeleteLogic) Delete(req *types.AccountBindingDel) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	tenantID := jwtx.GetUserTenantId64(l.ctx)

	res, err := l.svcCtx.AssetService.AccountBindingDel(l.ctx, &property_service.AccountBinding{
		ID:       req.ID,
		TenantID: tenantID,
	})
	if err != nil {
		return result.Err(err).End()
	}
	return result.Suc(res).End()
}
